<?php
class Application_Form_User extends Zend_Form
{// all by ammar
    public function init()
    {
        $validator = new Zend_Validate_Regex('([A-Za-z0-9]+)');
        $validator->setMessage(
        'Your username can only contain letters, numbers and underscores (_).');
        $validatorEmail = new Zend_Validate_EmailAddress();
        $validatorLength = new Zend_Validate_StringLength(array("min" => 4));

        $firstname = $this->createElement('text','fname');
        $firstname->setLabel('First Name:')
                    ->setRequired(false)
                    ->addValidator($validator)
                    ->addValidator($validatorLength);

        $lastname = $this->createElement('text','lname');
        $lastname->setLabel('Last Name:')
                    ->setRequired(false)
                    ->addValidator($validator)
                    ->addValidator($validatorLength);


        $email = $this->createElement('text','email');
        $email->setLabel('Email: *')
                ->setRequired(true)
                ->setAllowEmpty(false)
                ->addValidator($validatorEmail);

        $username = $this->createElement('text','username');
        $username->setLabel('Username: *')
                ->setRequired(true)
                ->setAllowEmpty(false)
                ->addValidator($validator)
                ->addValidator($validatorLength);

        $password = $this->createElement('password','password');
        $password->setLabel('Password: *')
                ->setRequired(true)
                ->setAllowEmpty(false)
                ->addValidator($validatorLength);

        $status = $this->createElement('select', 'status')
                ->setLabel('Status')
                ->setMultiOptions(array('pending' => 'Pending','enable' => 'Enable','disable'=>'Disable'));

        $register = $this->createElement('submit','register');
        $register->setLabel('Create')
                ->setIgnore(true);

        $date_created = $this->createElement('hidden','date_created');
        $token = $this->createElement('hidden','token');
        $this->addElements(array(
                        $firstname,
                        $lastname,
                        $email,
                        $username,
                        $password,
                        $status,
                        $date_created,
                        $token,
                        $register

        ));
    }
}
?>


